home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DStorage.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  8.1 KB  |  284 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DStorage.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Abstraction to deal with various types of stream-based     **
  7.  **                    storage devices.                                         **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **                                                                          **
  11.  **     Copyright (C) 1992-1997 Apple Computer, Inc.  All rights reserved.     **
  12.  **                                                                          **
  13.  **                                                                          **
  14.  *****************************************************************************/
  15. #ifndef QD3DStorage_h
  16. #define QD3DStorage_h
  17.  
  18. #include "QD3D.h"
  19.  
  20. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  21.  
  22. #if defined(__xlc__) || defined(__XLC121__)
  23.     #pragma options enum=small
  24. #endif
  25.  
  26. #include <Types.h>
  27. #include <Files.h>
  28.  
  29. #if defined(__xlc__) || defined(__XLC121__)
  30.     #pragma options enum=reset
  31.     #pragma options enum=int
  32.     #pragma options align=power
  33. #elif defined(__MWERKS__)
  34.     #pragma enumsalwaysint on
  35.     #pragma options align=native
  36. #elif defined(__MRC__) || defined(__SC__)
  37.     #if __option(pack_enums)
  38.         #define PRAGMA_ENUM_RESET_QD3DSTORAGE 1
  39.     #endif
  40.     #pragma options(!pack_enums)
  41.     #pragma options align=power
  42. #endif
  43.  
  44. #endif  /*  OS_MACINTOSH  */
  45.  
  46.  
  47. #if defined(OS_WIN32) && OS_WIN32
  48. #include <windows.h>
  49. #endif /* OS_WIN32 */
  50.  
  51.  
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif    /* __cplusplus */
  55.  
  56. /******************************************************************************
  57.  **                                                                             **
  58.  **                                Storage Routines                             **
  59.  **                                                                             **
  60.  *****************************************************************************/
  61.  
  62. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Storage_GetType(
  63.     TQ3StorageObject    storage);
  64.  
  65. QD3D_EXPORT TQ3Status QD3D_CALL Q3Storage_GetSize(
  66.     TQ3StorageObject    storage,
  67.     unsigned long        *size);
  68.  
  69. /* 
  70.  *    Reads "dataSize" bytes starting at offset in storage, copying into data. 
  71.  *    sizeRead returns the number of bytes filled in. 
  72.  *    
  73.  *    You may assume if *sizeRead < dataSize, then EOF is at offset + *sizeRead
  74.  */
  75.  
  76. QD3D_EXPORT TQ3Status QD3D_CALL Q3Storage_GetData(
  77.     TQ3StorageObject    storage,
  78.     unsigned long        offset,
  79.     unsigned long        dataSize,
  80.     unsigned char        *data,
  81.     unsigned long        *sizeRead);
  82.  
  83. /* 
  84.  *    Write "dataSize" bytes starting at offset in storage, copying from data. 
  85.  *    sizeWritten returns the number of bytes filled in. 
  86.  *    
  87.  *    You may assume if *sizeRead < dataSize, then EOF is at offset + *sizeWritten
  88.  */
  89.  
  90. QD3D_EXPORT TQ3Status QD3D_CALL Q3Storage_SetData(
  91.     TQ3StorageObject    storage,
  92.     unsigned long        offset,
  93.     unsigned long        dataSize,
  94.     const unsigned char    *data,
  95.     unsigned long        *sizeWritten);
  96.  
  97. /******************************************************************************
  98.  **                                                                             **
  99.  **                             Memory Storage Prototypes                         **
  100.  **                                                                             **
  101.  *****************************************************************************/
  102.  
  103. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3MemoryStorage_GetType(
  104.     TQ3StorageObject        storage);
  105.  
  106. /*
  107.  * These calls COPY the buffer into QD3D space
  108.  */
  109. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3MemoryStorage_New(
  110.     const unsigned char        *buffer,
  111.     unsigned long            validSize);
  112.  
  113. QD3D_EXPORT TQ3Status QD3D_CALL Q3MemoryStorage_Set(
  114.      TQ3StorageObject        storage,
  115.     const unsigned char        *buffer,
  116.     unsigned long            validSize);
  117.  
  118. /*
  119.  * These calls use the pointer given - you must dispose it when you're through
  120.  */
  121. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3MemoryStorage_NewBuffer(
  122.     unsigned char            *buffer,
  123.     unsigned long            validSize,
  124.     unsigned long            bufferSize);
  125.  
  126. QD3D_EXPORT TQ3Status QD3D_CALL Q3MemoryStorage_SetBuffer(
  127.      TQ3StorageObject        storage,
  128.     unsigned char            *buffer,
  129.     unsigned long            validSize,
  130.     unsigned long            bufferSize);
  131.  
  132. QD3D_EXPORT TQ3Status QD3D_CALL Q3MemoryStorage_GetBuffer(
  133.      TQ3StorageObject        storage,
  134.     unsigned char            **buffer,
  135.     unsigned long            *validSize,
  136.     unsigned long            *bufferSize);
  137.  
  138. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  139.  
  140. /******************************************************************************
  141.  **                                                                             **
  142.  **                                Macintosh Handles Prototypes                 **
  143.  **                                                                             **
  144.  *****************************************************************************/
  145.  
  146. /* Handle Storage is a subclass of Memory Storage */
  147.  
  148. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3HandleStorage_New(
  149.     Handle                    handle,
  150.     unsigned long            validSize);
  151.  
  152. QD3D_EXPORT TQ3Status QD3D_CALL Q3HandleStorage_Set(
  153.      TQ3StorageObject        storage,
  154.     Handle                    handle,
  155.     unsigned long            validSize);
  156.  
  157. QD3D_EXPORT TQ3Status QD3D_CALL Q3HandleStorage_Get(
  158.      TQ3StorageObject        storage,
  159.      Handle                    *handle,
  160.     unsigned long            *validSize);
  161.  
  162. /******************************************************************************
  163.  **                                                                             **
  164.  **                                Macintosh Storage Prototypes                 **
  165.  **                                                                             **
  166.  *****************************************************************************/
  167.  
  168. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3MacintoshStorage_New(                    
  169.     short                    fsRefNum);    /* Note: This storage is assumed open*/
  170.  
  171. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacintoshStorage_Set(
  172.      TQ3StorageObject        storage,
  173.     short                    fsRefNum);
  174.  
  175. QD3D_EXPORT TQ3Status QD3D_CALL Q3MacintoshStorage_Get(
  176.      TQ3StorageObject        storage,
  177.     short                    *fsRefNum);
  178.     
  179. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3MacintoshStorage_GetType(
  180.     TQ3StorageObject        storage);
  181.  
  182.  
  183. /******************************************************************************
  184.  **                                                                             **
  185.  **                            Macintosh FSSpec Storage Prototypes                 **
  186.  **                                                                             **
  187.  *****************************************************************************/
  188.  
  189. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3FSSpecStorage_New(
  190.     const FSSpec            *fs);
  191.  
  192. QD3D_EXPORT TQ3Status QD3D_CALL Q3FSSpecStorage_Set(
  193.      TQ3StorageObject        storage,
  194.     const FSSpec            *fs);
  195.  
  196. QD3D_EXPORT TQ3Status QD3D_CALL Q3FSSpecStorage_Get(
  197.      TQ3StorageObject        storage,
  198.     FSSpec                    *fs);
  199.  
  200. #endif  /*  OS_MACINTOSH  */
  201.  
  202. #if defined(OS_WIN32) && OS_WIN32
  203.  
  204. /******************************************************************************
  205.  **                                                                             **
  206.  **                            Win32 HANDLE Storage Prototypes                     **
  207.  **                                                                             **
  208.  *****************************************************************************/
  209.  
  210. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3Win32Storage_New(
  211.     const HANDLE            hFile);
  212.  
  213. QD3D_EXPORT TQ3Status QD3D_CALL Q3Win32Storage_Set(
  214.      TQ3StorageObject        storage,
  215.     const HANDLE            hFile);
  216.  
  217. QD3D_EXPORT TQ3Status QD3D_CALL Q3Win32Storage_Get(
  218.      TQ3StorageObject        storage,
  219.     const HANDLE            *hFile);
  220.  
  221. #endif  /*  OS_WIN32  */
  222.  
  223. /******************************************************************************
  224.  **                                                                             **
  225.  **                                    Unix Prototypes                             **
  226.  **                                                                             **
  227.  *****************************************************************************/
  228.  
  229. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3UnixStorage_New(
  230.     FILE                    *storage);
  231.  
  232. QD3D_EXPORT TQ3Status QD3D_CALL Q3UnixStorage_Set(
  233.      TQ3StorageObject        storage,
  234.     FILE                    *stdFile);
  235.  
  236. QD3D_EXPORT TQ3Status QD3D_CALL Q3UnixStorage_Get(
  237.      TQ3StorageObject        storage,
  238.     FILE                    **stdFile);
  239.     
  240. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3UnixStorage_GetType(
  241.     TQ3StorageObject        storage);
  242.  
  243.  
  244. /******************************************************************************
  245.  **                                                                             **
  246.  **                                Unix Path Prototypes                         **
  247.  **                                                                             **
  248.  *****************************************************************************/
  249.  
  250. QD3D_EXPORT TQ3StorageObject QD3D_CALL Q3UnixPathStorage_New(                    
  251.     const char                *pathName);                /* C string */
  252.  
  253. QD3D_EXPORT TQ3Status QD3D_CALL Q3UnixPathStorage_Set(            
  254.      TQ3StorageObject        storage,
  255.     const char                *pathName);                /* C string */
  256.  
  257. QD3D_EXPORT TQ3Status QD3D_CALL Q3UnixPathStorage_Get(            
  258.      TQ3StorageObject        storage,
  259.     char                    *pathName);                /* pathName is a buffer */
  260.  
  261. #ifdef __cplusplus
  262. }
  263. #endif    /* __cplusplus */
  264.  
  265. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  266.  
  267. #if defined(__xlc__) || defined(__XLC121__)
  268.     #pragma options enum=reset
  269.     #pragma options align=reset
  270. #elif defined(__MWERKS__)
  271.     #pragma enumsalwaysint reset
  272.     #pragma options align=reset
  273. #elif defined(__MRC__) || defined(__SC__)
  274.     #if PRAGMA_ENUM_RESET_QD3DSTORAGE
  275.         #pragma options(pack_enums)
  276.         #undef PRAGMA_ENUM_RESET_QD3DSTORAGE
  277.     #endif
  278.     #pragma options align=reset
  279. #endif
  280.  
  281. #endif  /* OS_MACINTOSH */
  282.  
  283. #endif /* QD3DStorage_h */
  284.